package main

import (
	"fmt"
	"strconv"
)

var topMap = make(map[int]string)

func init() {
	topMap[1] = "Gold Medal"
	topMap[2] = "Silver Medal"
	topMap[3] = "Bronze Medal"
}

func findRelativeRanks(score []int) []string {
	len := len(score)
	res := make([]string, len)

	var maxScore = 0
	for i := 0; i < len; i++ {
		if score[i] > maxScore {
			maxScore = score[i]
		}
	}

	var bucketLen = maxScore + 1
	bucket := make([]int, bucketLen)
	for i := 0; i < len; i++ {
		bucket[score[i]] = i + 1
	}

	var index = 0
	for i := 0; i < bucketLen; i++ {
		var j = bucketLen - i - 1
		var v = bucket[j]
		if v > 0 {
			index++
			if index < 4 {
				res[v-1] = topMap[index]
			} else {
				res[v-1] = strconv.Itoa(index)
			}
		}
	}

	return res[:]
}

func main() {
	var arr = [3]int{100, 101, 111111}
	fmt.Println(findRelativeRanks(arr[:]))
	var arr2 = [5]int{10, 3, 8, 9, 4}
	fmt.Println(findRelativeRanks(arr2[:]))
	var arr3 = [6]int{5, 4, 3, 2, 1, 0}
	fmt.Println(findRelativeRanks(arr3[:]))
}
